/*
 * Copyright (c) 2018 maoyan.com
 * All rights reserved.
 *
 */
package com.darren.euc.repository;

import com.darren.euc.entity.HaqiRecord;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

/**
 * 在这里编写类的功能描述
 *
 * @author fangwenhao
 * @created 2018/4/5
 */
@Transactional
public interface HaqiRecordRepository extends JpaRepository<HaqiRecord, Long> {

    @Modifying
    @Query("update HaqiRecord hq set hq.checkOutTime = ?1, hq.workTime = ?2, hq.status2 = ?3, hq.modTime = CURRENT_TIME where hq.faceUserId = ?4 and hq.recordId = ?5 and hq.checkDate = ?6")
    Integer updateHaqiRecord(Date checkOutTime, BigDecimal workTime, Integer status2, Long faceUserId, Long recordId, Date checkDate);

    List<HaqiRecord> findByFaceUserIdAndCheckDateBetween(Long faceUserId, Date start, Date end);

}
